import Home from '@/views/Home/Home.vue'
import { createRouter, createWebHistory } from 'vue-router'

export const routes = [
  {
    path: '/',
    name: 'Home',
    meta: { title: 'my首页' },
    component: Home,
  },
  {
    path: '/about',
    name: 'About',
    meta: {
      title: '关于',
      keepAlive: true,
    },
    component: () => import('@/views/About/About.vue'),
  },
  {
    path: '/:path(.*)', 
    component: Home,
  },
]

const router = createRouter({
  history: createWebHistory(),
  routes,
})

router.beforeEach((to, from) => {
  document.title = to.meta.title
})

export default router